package org.shiqianghh;

import java.io.File;
import java.nio.file.Path;
import java.nio.file.Paths;

import org.shiqianghh.tools.SoundPlay;
import org.shiqianghh.tts.DataUtils;

import ai.djl.Device;
import ai.djl.ndarray.NDManager;
/**
 * 1、目前只支持 biaobei这源声
 * 2、因为java的一下基础算和python的结果有区别，所以效果不稳定。
 * 3、有兴趣的可以改进,麻雀虽小五脏俱全
 * @author shiqianghh
 * 本项目仿照ttskit
 */
public class TTsUtil {
	public static void main(String[] args) throws Exception {
		 //被克隆的声音
		  //Path imageFile = Paths.get("src/main/resources/voice/biaobei-biaobei-009502.mp3");
		  Path imageFile = Paths.get("src/main/resources/voice/biaobei-biaobei-009502.mp3");
		  //语音保存路径
		  File outs = new File(Paths.get("build/output")+"/audio_example.wav");
		  //设置为pytorch引擎
		  System.setProperty("ai.djl.default_engine", "PyTorch");
		  NDManager manager = NDManager.newBaseManager(Device.cpu());  
		  
		  DataUtils.tts(imageFile.toString(),"这是第一个家洼开发的文本转语音项目",outs,manager);
		  
		  manager.close();
		  SoundPlay sound = new SoundPlay(outs);
	      sound.play(); 
	}
}
